package com.sky.mapper;

import com.sky.dto.EmployeeDto;
import com.sky.dto.EmployeeLoginDTO;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;


@Mapper
@Component
public interface EmployeeMapper {

    //登录

    Employee selectByUsernameAndPassword(EmployeeLoginDTO loginDTO);
    Employee selectByUsername(String username);


    //分页
    //@Select("select * from employee")
    List<Employee> list(String name);

    //修改员工密码
    @Update("update employee set password = #{newPassword}  where id = #{empId} and password =#{oldPassword} ")
    void updatePass(EmployeeDto employeeDto);

    //添加员工
    @Insert("insert into employee (id_Number, name, phone, sex, username, password) " +
            "values (#{idNumber}, #{name}, #{phone}, #{sex}, #{username}, #{password})")
    void save(Employee employee);

    //根据id查询员工
    @Select("select * from employee where id = #{id}")
    Employee selectById(Long id);


    void update(Employee employee);

    //修改员工
    @Update("update employee set id_Number =#{idNumber}, name =#{name}, phone =#{phone}, sex =#{sex}, username =#{username} where id = #{id}")
    Integer updateEmp(Employee employee);
}
